package com.example.myapplication.database.room.dao;


import android.database.Cursor;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import com.example.myapplication.database.room.pojo.Users;
import com.example.myapplication.enity.User;

import java.util.List;

@Dao
public interface UserDao {
    @Query("SELECT * FROM users")
    List<Users> getAll();

    @Query("SELECT * FROM users")
    Cursor getAll1();

    @Query("SELECT * FROM users WHERE uid IN (:userIds)")
    List<Users> loadAllByIds(int[] userIds);

    @Query("SELECT * FROM users WHERE user_name LIKE :userName")
    Users findByName(String userName);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertAll(Users... users);

    //@Query("delete from users where user_name =="" user")
    //@Query("delete from users where user_name == :user")
    @Delete
    void delete(Users user);

    @Update
    //@Query("update users set user_name = users.user_name and user_age = users.user_age and user_height = users.user_height where uid = users.uid")
    void update(Users users);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insert(Users user);
}
